//游戏数据类
class GameData {
    static gameWidth:number = 480;
    static gameHeight:number = 800;
    static scaleSmall:number = 1;
    static gameOver:boolean = false;//标示游戏结束
    static isIntruction:boolean = false;//标示现在是否是游戏介绍页面

    static leastNum:number = 2;//最少可以消除的元素数量
    static colorNum:number = 5;//彩色圆圈的颜色种类
    static Map:any; //地图标签，用于标示上半部分坐标内是否被占用
    static MapWidth:number = 5;
    static MapHeight:number = 6;
    static score:number = 0;
    static goldNum:number = 0;
    static goldChance:number = 0.5;//获取金币的概率

    static enemyNum:number = 4;//共设4个敌人
    static enemyTypeNum:number = 3;//敌人的种类
    static enemyFlashSpace:number = 500;//刷新敌人的时间间隔
    static enemyFlashLestSpace:number = 300;//最快刷新敌人的时间间隔
    static enemyFlashSpeed:number = 5;//刷新加快的步长
    static iceTime:number = 200;//冰霜效果持续时间
    static windTime:number = 20;//风力效果持续时间
    static heroHit:boolean = false;//标示hero是否被攻击
    static elemNum:number = 0;//连续消除的元素个数
    static hero:string = "Hero1";//出战的英雄名字
    static attackType:string = "empty";//标示hero的攻击类型

    static tempX:number = 0;//保存第一个敌人的X


    //重置参数
    static reset() {
        //初始化地图//全部设置为空
        GameData.Map = [];
        for (var y = 0; y < GameData.MapHeight; y++) {
            GameData.Map[y] = [];
            for (var x = 0; x < GameData.MapWidth; x++) {
                GameData.Map[y][x] = -1;
            }
        }

        //重置各种参数
        GameData.score = 0;
        GameData.enemyFlashSpace = 500;//刷新敌人的时间间隔
        GameData.attackType = "empty";//标示hero的攻击类型
        GameData.heroHit = false;//标示hero是否被攻击
        GameData.gameOver = false;//标示游戏结束
        GameData.elemNum = 0;//连续消除的元素个数
        GameData.Enemy1.blood = 100;
        GameData.Enemy2.blood = 50;
        GameData.Enemy3.blood = 150;
        GameData.Enemy1.speed = 0.8;
        GameData.Enemy2.speed = 1;
        GameData.Enemy3.speed = 0.5;
    }

    //角色初始数值//////////////////////////////////////////
    static Attack = {
        "fire": 60,//火焰攻击力
        "fireUp": 20,//额外火焰攻击力
        "thunder": 20,//雷电攻击力
        "thunderUp": 10,//额外雷电攻击力
        "ice": 20,//冰雪攻击力
        "iceUp": 10,//额外冰雪攻击力
        "wind": 4,//风的推送距离
        "windUp": 2,//额外风的推送距离
        "blood": 100,//保护罩保护时间
        "bloodUp": 25,//额外保护罩保护时间
    };

    static Hero1 = {
        "activation": true,
        "name": "Hero1",
        "cost": 300,
        "offsetX": -30,
        "offsetY": 125,
        "scale": 0.8,
    };


    static Hero2 = {
        "activation": false,
        "name": "Hero2",
        "cost": 300,
        "offsetX": -30,
        "offsetY": 135,
        "scale": 0.8,
    };


    static Hero3 = {
        "activation": false,
        "name": "Hero3",
        "cost": 300,
        "offsetX": -60,
        "offsetY": 135,
        "scale": 0.8,
    };

    static Enemy1 = {
        "name": "Enemy1",
        "blood": 150,
        "speed": 0.8,
        "scale": 0.8,
        "offsetX": -10,
        "offsetY": 130
    };

    static Enemy2 = {
        "name": "Enemy2",
        "blood": 100,
        "speed": 1,
        "scale": 0.9,
        "offsetX": 0,
        "offsetY": 135
    };


    static Enemy3 = {
        "name": "Enemy3",
        "blood": 200,
        "speed": 0.5,
        "scale": 0.8,
        "offsetX": 0,
        "offsetY": 135
    };

    //加载数据
    static loadData():void {
        var nameList = ["Hero1", "Hero2", "Hero3"];//角色列表.
        for (var i = 0; i < nameList.length; i++) {
            if (Tool.checkLocal(nameList[i])) {//若本地端有保存数据
                GameData[nameList[i]] = JSON.parse(Tool.getLocal(nameList[i]));
            }
        }
        GameData.goldNum = Tool.getLocal("goldNum");
        if (GameData.goldNum == null)GameData.goldNum = 0;
    }

    //保存数据//角色数据//基本数据（金币数）
    static saveData():void {
        var nameList = ["Hero1", "Hero2", "Hero3"];//角色列表.
        for (var i = 0; i < nameList.length; i++)
            Tool.setLocal(nameList[i], JSON.stringify(GameData[nameList[i]]));
        Tool.setLocal("goldNum", GameData.goldNum);
    }

}